/*
 * Copyright 2013 Glassy Cinema.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package hu.glassy.core.model;

import hu.glassy.model.common.SortableAbstractEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author Alexander Molnár <molnar.alexander@sonrisa.hu>
 */
@Entity
@Table(name = "movie2person", uniqueConstraints =
{
  @UniqueConstraint(columnNames =
  {
    "movie_id", "person_id", "role_id"
  })
})
public class MovieRole extends SortableAbstractEntity
{

  public static final int ROLE_DESCRIPTION_LENGTH = 64;

  @ManyToOne
  @JoinColumn(name = "movie_id", referencedColumnName = "id", nullable = false, unique = false)
  private Movie movie;

  @ManyToOne
  @JoinColumn(name = "person_id", referencedColumnName = "id", nullable = false, unique = false)
  private Person person;

  @ManyToOne
  @JoinColumn(name = "role_id", referencedColumnName = "id", nullable = false, unique = false)
  private Code role;

  @Column(name = "role_description", length = ROLE_DESCRIPTION_LENGTH, nullable = true, unique = false)
  private String roleDescription;

  /**
   * @return the movie
   */
  public Movie getMovie()
  {
    return movie;
  }

  /**
   * @param movie the movie to set
   */
  public void setMovie(Movie movie)
  {
    this.movie = movie;
  }

  /**
   * @return the person
   */
  public Person getPerson()
  {
    return person;
  }

  /**
   * @param person the person to set
   */
  public void setPerson(Person person)
  {
    this.person = person;
  }

  /**
   * @return the role
   */
  public Code getRole()
  {
    return role;
  }

  /**
   * @param role the role to set
   */
  public void setRole(Code role)
  {
    this.role = role;
  }

  /**
   * @return the roleDescription
   */
  public String getRoleDescription()
  {
    return roleDescription;
  }

  /**
   * @param roleDescription the roleDescription to set
   */
  public void setRoleDescription(String roleDescription)
  {
    this.roleDescription = roleDescription;
  }

}
